home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2001 December / pcwk12201b.iso / Wersje pelne i specjalne / Winamp 2.77 i 3.0beta / wasabi-sdk_beta1.exe / studio / common / buttwnd.h < prev    next >
C/C++ Source or Header  |  2001-10-08  |  5KB  |  160 lines

  1. /*
  2.  
  3.   Nullsoft WASABI Source File License
  4.  
  5.   Copyright 1999-2001 Nullsoft, Inc.
  6.  
  7.     This software is provided 'as-is', without any express or implied
  8.     warranty.  In no event will the authors be held liable for any damages
  9.     arising from the use of this software.
  10.  
  11.     Permission is granted to anyone to use this software for any purpose,
  12.     including commercial applications, and to alter it and redistribute it
  13.     freely, subject to the following restrictions:
  14.  
  15.     1. The origin of this software must not be misrepresented; you must not
  16.        claim that you wrote the original software. If you use this software
  17.        in a product, an acknowledgment in the product documentation would be
  18.        appreciated but is not required.
  19.     2. Altered source versions must be plainly marked as such, and must not be
  20.        misrepresented as being the original software.
  21.     3. This notice may not be removed or altered from any source distribution.
  22.  
  23.  
  24.   Brennan Underwood
  25.   brennan@nullsoft.com
  26.  
  27. */
  28.  
  29. #ifndef _BUTTWND_H
  30. #define _BUTTWND_H
  31.  
  32. #include "common.h"
  33. #include "canvas.h"
  34. #include "autobitmap.h"
  35. #include "clickwnd.h"
  36. #include "skinclr.h"
  37.  
  38. class Region;
  39.  
  40. #define DEFAULT_BUTTON_TEXT_SIZE 14
  41. typedef enum {
  42.   BUTTONJUSTIFY_LEFT,
  43.   BUTTONJUSTIFY_CENTER
  44. } ButtonJustify;
  45.  
  46. #define BUTTONWND_PARENT ClickWnd
  47. class COMEXP ButtonWnd : public BUTTONWND_PARENT {
  48. public:
  49.   ButtonWnd();
  50.   virtual ~ButtonWnd();
  51.  
  52.   virtual int onPaint(Canvas *canvas);
  53.  
  54.   // methods to modify button looks
  55.   int setBitmaps(const char *normal, const char *pushed=NULL, const char *hilited=NULL, const char *activated=NULL);
  56.   int setBitmaps(HINSTANCE hInst, int normal, int pushed, int hilited, int activated);
  57.   int setRightBitmap(char *bitmap);
  58.   int setBitmapCenter(int centerit);
  59.   void setUseBaseTexture(int useit);
  60.   void setBaseTexture(SkinBitmap *bmp, int x, int y, int tile=0);
  61.   int setButtonText(const char *text, int size=DEFAULT_BUTTON_TEXT_SIZE);
  62.   void setTextJustification(ButtonJustify jus);
  63.   // id will be param1 in child notify msgs
  64.   void setButtonId(int id) { buttonid = id; }
  65.   int getButtonId() const { return buttonid; }
  66.   void setWantFocus(int want) { iwantfocus = !!want; }
  67.   virtual int wantFocus() const { return iwantfocus; }
  68.   void setRectRgn(int r);
  69.   virtual void onLeaveArea();
  70.  
  71.   int getWidth();    // our preferred width and height (from bitmaps)
  72.   int getHeight();
  73.  
  74.   virtual int onGetFocus();
  75.   virtual int onKillFocus();
  76.   virtual int onChar(char c);
  77.  
  78.   virtual void setAlpha(int a);
  79.   virtual int getAlpha(void) const;
  80.  
  81.   void enableButton(int enabled);    // can be pushed
  82.  
  83.   virtual void onLeftPush(int x, int y);
  84.   virtual void onRightPush(int x, int y);
  85.   virtual void onLeftDoubleClick(int x, int y);
  86.   virtual void onRightDoubleClick(int x, int y);
  87.  
  88.   virtual int onResize();
  89.  
  90.   virtual int onMouseMove(int x, int y);    // need to catch region changes
  91.  
  92.   virtual int onEnable(int is);
  93.   virtual int getEnabled() const;
  94.   virtual int getPreferences(int what);
  95.  
  96.   virtual int userDown() { return userdown; }
  97.   virtual int wantClicks() { return getEnabled(); }
  98.  
  99.   void setCheckBitmap(char *checkbm);
  100.   void setChecked(int c) { checked=c; }; // <0=nocheck, 0=none, >0=checked
  101.   int  getChecked() const { return checked; }
  102.   void setHilite(int h);
  103.   int getHilite();
  104.   void setPushed(int p); // used by menus to simulate pushing
  105.   int getPushed() const; // used by menus to simulate pushing
  106.   void setAutoDim(int ad) { autodim=!!ad; } // nonzero makes it dim if there's no hilite bitmap
  107.   int getAutoDim() const { return autodim; } // nonzero makes it dim if there's no hilite bitmap
  108.   void setActivatedButton(int a);
  109.   int getActivatedButton() const;
  110.   void setBorders(int b) { borders=!!b; }
  111.   int getBorders() const { return borders; }
  112.   void setFolderStyle(int f) { folderstyle = !!f; }
  113.   void setInactiveAlpha(int a) { inactivealpha=a; }
  114.   void setActiveAlpha(int a) { activealpha=a; }
  115.  
  116.   void setColors(const char *text="studio.button.text", const char *hilite="studio.button.hiliteText", const char *dimmed="studio.button.dimmedText");
  117.   virtual void freeResources();
  118.   virtual void reloadResources();
  119.  
  120.   virtual int onActivateButton(int active);
  121.  
  122.   virtual int onActivate();
  123.   virtual int onDeactivate();
  124.  
  125. protected:
  126.   virtual BOOL mouseInRegion(int x, int y);    // from ClickWnd
  127.  
  128. private:
  129.   AutoSkinBitmap normalbmp, pushedbmp, hilitebmp, checkbmp, rightbmp, activatedbmp;
  130.   SkinBitmap *base_texture;
  131.   Region *normalrgn, *pushedrgn, *hirgn, *currgn, *activatedrgn;
  132. //CUT  char *label;
  133.   int textsize, buttonid;
  134.   ButtonJustify textjustify;
  135. //  char *color_text,*color_hilite,*color_dimmed;
  136.   SkinColor color_text, color_hilite, color_dimmed;
  137.  
  138.     String normalBmpStr, pushedBmpStr, hilitedBmpStr, activatedBmpStr;
  139.  
  140.   int folderstyle:1;
  141.   int autodim:1;
  142.   int userhilite:1;
  143.   int userdown:1;
  144.   int activated:1;
  145.   int enabled:1;
  146.   int borders:1;
  147.   int hilited;
  148.   int iwantfocus:1;
  149.   int center_bitmap:1;
  150.   int use_base_texture:1;
  151.  
  152.   int checked;
  153.   int xShift, yShift, tile_base_texture;
  154.   int rectrgn;
  155.  
  156.   int alpha, inactivealpha, activealpha;
  157. };
  158.  
  159. #endif
  160.